package com.example.eeuse.config;


import etcd.IConfigCenter;
import etcd.JdEtcdBuilder;
import etcd.JdEtcdClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wuweifeng
 * @version 1.0
 * @date 2020-07-27
 */
@ConditionalOnProperty(prefix = "etcd",name = "enable",havingValue = "true",matchIfMissing = true)
@Configuration
public class EtcdConfig {

    @Value("${etcd.server}")
    private String etcd;
    @Value("${etcd.enable}")
    private boolean enable;

    @Bean
    public JdEtcdClient client() {
        //连接多个时，逗号分隔
        return JdEtcdBuilder.build(etcd);
    }
}
